package gyn.fgsl.adapters;

import gyn.fgsl.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

public class ExpandableListViewCalendario extends BaseExpandableListAdapter{

	private String[][] eventos;
	private String[] horarios;
	private Context mContext;
	private int paiResource;
	private int filhoResource;
	
	public ExpandableListViewCalendario(String[] horarios, String [][] programacao, Context context){
		super();
		this.eventos = programacao;
		this.horarios = horarios;
		this.mContext = context;
		paiResource = R.layout.calendario_eventos_horario;
		filhoResource = R.layout.calendario_eventos_item;
	}
	
	@Override
	public Object getChild(int arg0, int arg1) {
		return eventos[arg0][arg1];
	}

	@Override
	public long getChildId(int arg0, int arg1) {
		return 0;
	}

	@Override
	public View getChildView(int arg0, int arg1, boolean arg2, View converView,
			ViewGroup arg4) {
		LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		converView = inflater.inflate(filhoResource, null);
		((TextView) converView.findViewById(R.id.text_nome_evento)).setText(eventos[arg0][arg1]);
		return converView;
	}

	@Override
	public int getChildrenCount(int arg0) {
		// TODO Auto-generated method stub
		return eventos[arg0].length;
	}

	@Override
	public Object getGroup(int arg0) {
		// TODO Auto-generated method stub
		return horarios;
	}

	@Override
	public int getGroupCount() {
		// TODO Auto-generated method stub
		return horarios.length;
	}

	@Override
	public long getGroupId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getGroupView(int arg0, boolean arg1, View convertView, ViewGroup arg3) {
		LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		convertView = inflater.inflate(paiResource, null);
		((TextView)convertView.findViewById(R.id.text_horario_evento)).setText(horarios[arg0]);
		return convertView;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isChildSelectable(int arg0, int arg1) {
		// TODO Auto-generated method stub
		return false;
	}

}
